package com.lg.wxq.http;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import android.graphics.drawable.BitmapDrawable;

import com.lg.wxq.utils.StringUtils;

public class HttpClient {
	private static HttpClient instance=new HttpClient();
	
	private HttpClient(){
		
	}
	
	public static HttpClient getInstance(){
		return instance;
	}

	public BitmapDrawable getImage(String imageUrl) {
		BitmapDrawable drawable = null;
		if (StringUtils.isNotBlank(imageUrl)) {
			try {
				URL url = new URL(imageUrl);
				HttpURLConnection conn = (HttpURLConnection) url.openConnection();
				InputStream in = conn.getInputStream();
				drawable = new BitmapDrawable(in);
				in.close();
				return drawable;
			} catch (IOException e) {
				return null;
			}
		}
		return drawable;

	}

}
